fix(python/server): make MCP discovery work (ucp wrapper + minimal /mcp endpoint)#113
Open
dzuluaga wants to merge 4 commits into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…ery profile The /.well-known/ucp handler unwrapped the ucp key from its own template before responding, so the served body was a flat object. The UCP discovery profile schema (discovery/profile.json) requires the top-level ucp object ($defs.base.required = ["ucp"], for both 2026-01-23 and 2026-04-08), so spec-conformant clients reject the served profile with PROFILE_SCHEMA_INVALID. Return the wrapped template as-is and default payment_handlers inside the ucp object rather than at the document root. The Node sample (rest/nodejs/src/api/discovery.ts) already serves the wrapped shape.
1887122 to
2f65401
Compare
The discovery profile advertises an mcp transport at <endpoint>/mcp, but the server only implemented REST, so MCP clients failed discovery with HTTP 404 on that endpoint. Add a minimal JSON-RPC /mcp route handling initialize and tools/list (advertising the five shopping checkout methods from the UCP shopping OpenRPC), so spec-conformant MCP clients can complete discovery. tools/call bridging to the REST checkout handlers is left as a follow-up.
The flower_shop happy-path client read payment_handlers from the document root, which only worked with the non-conformant flat discovery profile. Now that the server serves the spec-required {ucp: {...}} wrapper, read payment_handlers from inside ucp (with a root fallback for flat/legacy profiles). Without this, the happy path aborts at the payment step with 0 payment handlers.
Wrap the JSONResponse error payload and the notifications guard to satisfy ruff-format (line-length 80, indent-width 2).
Author
|
Friendly nudge @westeezy / @jingyli 🙏 This one's approved by @igrigorik and all checks are green, just needs a 2nd approval to land. Would either of you mind taking a quick look? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the Python reference server's UCP discovery work end-to-end for spec-conformant MCP clients, and keeps the bundled REST happy-path client working with the now-conformant profile. Three related changes:
ucpwrapper./mcpendpoint the profile advertises (minimal: enough for discovery).payment_handlersfrom insideucp.1. Preserve required top-level
ucpwrapper (routes/discovery.py)The
/.well-known/ucphandler unwrapped theucpkey from its own template before responding, emitting a flat profile. The UCP discovery-profile schema (discovery/profile.json→$defs.base.required = ["ucp"], for both2026-01-23and2026-04-08) requires the wrapper, so conformant clients reject it:Fix: return the wrapped template as-is; default
payment_handlersinside theucpobject. (The Node sample already serves the wrapped shape.)2. Add a minimal MCP endpoint (
routes/mcp.py)The profile advertises an
mcptransport at<endpoint>/mcp, but only REST routes were mounted, so MCP clients got HTTP 404 at that endpoint:Fix: add a JSON-RPC
/mcproute handlinginitializeandtools/list, advertising the five shopping checkout methods (create_checkout,get_checkout,update_checkout,complete_checkout,cancel_checkout) from the UCP shopping OpenRPC. Tool execution (tools/call) bridging to the existing REST checkout handlers is intentionally left as a follow-up.3. Client reads
payment_handlersfrom theucpwrapper (client/flower_shop/simple_happy_path_client.py)The happy-path client read
payment_handlersfrom the document root, which only worked with the (non-conformant) flat profile. Once the server is fixed (#1),payment_handlerslives underucp, so the client found 0 handlers and aborted at the payment step. Fix: read fromucp.payment_handlers(with a root fallback for legacy/flat profiles).Verification
Scope
rest/python/server+ the bundledrest/python/client/flower_shopclient. The Node sample (rest/nodejs) already serves the wrapped profile and is untouched.tools/callexecution over MCP is out of scope (left as a follow-up).🤖 Generated with Claude Code